from flask import Flask
from configs import config
from extensions import register_extensions
from com.utils import setup_log
from apps.views import register_blueprint
from apps.apis import register_api
import orms
import com


def create_app(config_name='dev'):  # 注册app
    app = Flask('LiuX')

    # app.secret_key = 'notes.zhengxinonly.com'
    # 配置文件
    app.config.from_object(config.get(config_name))  # 如果有则config_name，否则‘dev’
    print(config.get(config_name))
    # 导入插件
    register_extensions(app)
    # 日志配置
    setup_log(config_name='dev')
    # 蓝图绑定
    register_blueprint(app)
    # 注册接口
    register_api(app)
    return app
